<template>
  <div id="app">
    <div class="tabItem">
      <div
        class="item"
        :class="selctIndex==indexlimt?'':'borderVit'"
        v-for="(tabItem,indexlimt) in tabTitle"
        :key="indexlimt"
        @click="handlerMorf(indexlimt)"
      >
        <img class="tabImage" :src="tabItem.iconUrl" />
        <div class="tranClo" v-if="selctIndex==indexlimt"></div>
        <div class="item_title" :class="selctIndex==indexlimt?'colorVit':''">{{tabItem.name}}</div>
      </div>
    </div>

    <div class="recycler_box">
      <div
        class="recycler"
        v-for="(item,indexData) in data"
        :key="indexData"
        @click="navDetails(item.id)"
      >
        <img class="item_img" :src="item.coverUrl" />
        <div class="item_name">{{item.title}}</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'visualStar',
  data() {
    return {
      selctIndex: this.$route.query.index,
      tid: this.$route.query.tid,
      tabTitle: [],
      data: []
    }
  },
  mounted() {
    let that = this
    this.$http({
      url: 'https://testbzhz.jnbygroup.com/api/gateway/dealer-center/dealer/categoryList',
      method: 'get',
      params: {
        moduleId: that.tid
      }
    }).then(data => {
      if (data.code == 200) {
        console.log(data)
        that.tabTitle = data.data
        that.listData()
      } else {
        this.$toast(data.msg)
      }
    })
  },
  computed: {},
  created: function() {
    // document.title = '员工福利'
  },
  methods: {
    navDetails(cid) {
      this.$router.push({ path: 'detailsView', query: { cid: cid } })
    },

    handlerMorf(indexlimit) {
      this.selctIndex = indexlimit
      this.listData()
    },

    listData() {
      let that = this
      this.$http({
        url: 'https://testbzhz.jnbygroup.com/api/gateway/dealer-center/dealer/queryContentListByCategoryId',
        method: 'post',
        // params: {
        //   tel: '15139678571',
        // },
        data: {
          categoryId: that.tabTitle[that.selctIndex].id
        }
      }).then(data => {
        if (data.code == 200) {
          console.log(data)
          that.data = data.data.records
        } else {
          this.$toast(data.msg)
        }
      })
    }
  }
}
</script>
<style scoped>
#app {
  height: 100vh;
}

.tabItem {
  width: 94%;
  display: flex;
  align-items: center;
  margin-left: 4%;
  overflow: scroll;
  scrollbar-width: none; /* firefox */
  -ms-overflow-style: none; /* IE 10+ */
}

::-webkit-scrollbar {
  display: none; /* Chrome Safari */
}

.item {
  margin-right: 10px;
  width: 108px;
  height: 60px;
  border-radius: 5px;
  border: 1px solid #327542;
  position: relative;
}

.borderVit {
  border: 1px solid #ffffff;
}

.tabImage {
  width: 106px;
  height: 58px;
  overflow: hidden;
  border-radius: 5px;
}

.tranClo {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 106px;
  height: 58px;
  background: rgba(255, 255, 255, 0.6);
  z-index: 2;
  border-radius: 5px;
}

.item_title {
  position: absolute;
  top: 0px;
  left: 0px;
  width: 106px;
  line-height: 58px;
  text-align: center;
  z-index: 3;
  color: #ffffff;
  border-radius: 5px;
}

.colorVit {
  color: #327542;
}

.recycler_box {
  width: 94%;
  display: flex;
  align-items: center;
  margin-left: 4%;
  flex-wrap: wrap;
  overflow: auto;
  justify-content: space-between;
}

.recycler {
  margin-top: 20px;
  width: 44.8vw;
}

.item_img {
  width: 44.8vw;
  height: 94px;
  overflow: hidden;
}

.item_name {
  margin-top: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #333333;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
}

/* <div>
    <div class="tabItem">
      <div class="item" v-for="(tabItem,indexlimt) in tabTitle" :key="indexlimt">
        <img class="tabImage" />
        <div class="item">{{tabItem.name}}</div>
      </div>
    </div>

    <div class="recycler" v-for="(item,indexData) in data" :key="indexData">
      <img class="item_img" />
      <div class="item_name">{{item.title}}</div>
    </div>
  </div> */
</style>